/*     */ package com.qmsk.business.manage.funcMenuDetail.controller;
/*     */ 
/*     */ import com.qmsk.business.manage.funcMenuDetail.dao.FuncMenuDtDAO;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"wx/funcMenuDt"})
/*     */ public class FuncMenuDtController
/*     */ {
/*  32 */   private static final Logger logger = Logger.getLogger(FuncMenuDtController.class);
/*     */ 
/*     */   @Autowired
/*     */   private FuncMenuDtDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/key/{key}/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(@PathVariable("key") String key, @PathVariable("shopId") Long shopId, HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  51 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(key, shopId);
/*  52 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  54 */       logger.error(e);
/*  55 */       ResponseUtils.setErrorMsgResponse(
/*  56 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  75 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  77 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(id, nPageIdx, 
/*  78 */         nPageSize);
/*  79 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  81 */       logger.error(e);
/*  82 */       ResponseUtils.setErrorMsgResponse(
/*  83 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 100 */       int nResult = 0;
/* 101 */       Long id = null;
/* 102 */       String sData = RequestUtils.getStringOfData(request);
/* 103 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 104 */       if (p != null) {
/* 105 */         nResult = this.dao.applyUpdates(p);
/* 106 */         if (nResult > 0) {
/* 107 */           id = this.dao.getLastId();
/* 108 */           DbConnection.commit();
/*     */         } else {
/* 110 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 113 */       if (id != null) {
/* 114 */         String[] heads = { "id" };
/* 115 */         Object[] datas = { id };
/* 116 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/* 117 */         return; }
/* 118 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 119 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 120 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 123 */       logger.error(e);
/* 124 */       DbConnection.rollback();
/* 125 */       ResponseUtils.setErrorMsgResponse(
/* 126 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 127 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 143 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 145 */       String[] strParams = id.split(",");
/* 146 */       int nResult = this.dao.deleteParams(strParams);
/* 147 */       DbConnection.commit();
/* 148 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 149 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 150 */         response);
/*     */     } catch (Exception e) {
/* 152 */       DbConnection.rollback();
/* 153 */       logger.error(e);
/* 154 */       ResponseUtils.setErrorMsgResponse(
/* 155 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 156 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 172 */     String sData = RequestUtils.getStringOfData(request);
/*     */     try {
/* 174 */       int nResult = 0;
/* 175 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 176 */       if (p != null) {
/* 177 */         nResult = this.dao.applyUpdates(p);
/* 178 */         if (nResult > 0)
/* 179 */           DbConnection.commit();
/*     */         else {
/* 181 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 185 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 186 */         RequestUtils.getSqlUpdateErrorMessage(sData, request), 
/* 187 */         response);
/*     */     } catch (Exception e) {
/* 189 */       DbConnection.rollback();
/* 190 */       logger.error(e);
/* 191 */       ResponseUtils.setErrorMsgResponse(
/* 192 */         RequestUtils.getSqlUpdateErrorMessage(sData, request) + 
/* 193 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.manage.funcMenuDetail.controller.FuncMenuDtController
 * JD-Core Version:    0.5.3
 */